from selenium.webdriver import ActionChains
import time
from appium import webdriver
from selenium.webdriver.common.actions.mouse_button import MouseButton

abc = {
    "platformName": "Android",
    "platformVersion": "7.1.2",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.settings",
    "appActivity": ".Settings"
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', abc)
# 隐式等待
driver.implicitly_wait(10)
# 进入图库，选择图片，放大
driver.start_activity("com.android.gallery3d", ".app.GalleryActivity")

actions = ActionChains(driver)
f1 = actions.w3c_actions.add_pointer_input('touch', 'f1')
f1.create_pointer_move(x=520, y=860)
f1.create_pointer_down()
f1.create_pointer_up(MouseButton.LEFT)
actions.perform()

time.sleep(2)

f2 = actions.w3c_actions.add_pointer_input('touch', 'f2')
for i in range(3):
    f1.create_pointer_move(x=520, y=860)
    f2.create_pointer_move(x=520, y=860)
    f1.create_pointer_down()
    f2.create_pointer_down()
    f1.create_pointer_move(x=1000, y=300)
    f2.create_pointer_move(x=100, y=1700)
    f1.create_pointer_up(MouseButton.LEFT)
    f2.create_pointer_up(MouseButton.LEFT)
    actions.perform()
    time.sleep(2)
driver.quit()